/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

/**
 *
 * @author arnold
 */
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.sql.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Transient;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

@Entity
@Table(name="features_products")

public class FeatureProduct extends BaseObject implements Serializable {

    private Long id;
    private String name;
    private String description;
    private String nameEs;
    private String descriptionEs;

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name="description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name="name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FeatureProduct other = (FeatureProduct) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if ((this.description == null) ? (other.description != null) : !this.description.equals(other.description)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 89 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 89 * hash + (this.description != null ? this.description.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE)
                .append("id", this.id)
                .append("name", this.name)
                .append("description", this.description);
        return sb.toString();
    }

    /**
     * @return the nameEs
     */
    @Column(name = "name_es")
    public String getNameEs() {
        return nameEs;
    }

    /**
     * @param nameEs the nameEs to set
     */
    public void setNameEs(String nameEs) {
        this.nameEs = nameEs;
    }

    /**
     * @return the descriptionEs
     */
    @Column(name = "description_es")
    public String getDescriptionEs() {
        return descriptionEs;
    }

    /**
     * @param descriptionEs the descriptionEs to set
     */
    public void setDescriptionEs(String descriptionEs) {
        this.descriptionEs = descriptionEs;
    }
        @Transient
    public String getNameLang() {
        if (getLanguaje() != null && getLanguaje().equals("es") && getNameEs() != null) {
            return getNameEs();
        }
        return getName();
    }
        @Transient
    public String getDescriptionLang() {
        if (getLanguaje() != null && getLanguaje().equals("es") && getDescriptionEs() != null) {
            return getDescriptionEs();
        }
        return getDescription();
    }


}
